#!/bin/sh
#
# /etc/rc.d/init.d/toughradius
#
# toughradius is a radius server
#
# chkconfig: - 64 36
# description: toughradius Server
# processname: toughradius

# Source init functions
. /etc/rc.d/init.d/functions

prog="supervisord"
prog_bin="/usr/local/bin/supervisord"
PIDFILE="/var/toughradius/supervisord.pid"

start()
{
        echo -n $"Starting $prog: "
        daemon $prog_bin --pidfile $PIDFILE -c /etc/toughradius.conf
        [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
        echo
}

stop()
{
        echo -n $"Shutting down $prog: "
        [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
        echo
}

case "$1" in

  start)
    start
  ;;

  stop)
    stop
  ;;

  status)
        status $prog
  ;;

  restart)
    stop
    start
  ;;

  *)
    echo "Usage: $0 {start|stop|restart|status}"
  ;;

esac